﻿using System;
using System.Collections.Generic;
using System.Web;
using Ecreate.Popedom;
using Newtonsoft.Json;
namespace Ecreate.Web.popedom.data
{
    
    public class json : IHttpHandler
    {

        private Ecreate.Popedom.Service.IGroupService groupservice = new Ecreate.Popedom.Service.SpringImpl.GroupServiceImpl();

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            IList<tGroup> l = groupservice.getAll();
            List<JsonValueObject> jlist = new List<JsonValueObject>();
            foreach (tGroup g in l)
            {
                JsonValueObject j = new JsonValueObject();
                j.Id = g.Grouplevel.Id + "." + g.Id;
                j.Value = g.Groupname;
                jlist.Add(j);
            }
            JsonValueObject jsearch=new JsonValueObject();
            jsearch.Id="";jsearch.Value="请选择";
            jlist.Insert(0, jsearch);
            string jsondata= JsonConvert.SerializeObject(jlist);
            context.Response.Write(jsondata);

        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}
